<?php

namespace maoxuner\LaravelJsonRpc\Exceptions;

use Throwable;

/**
 * NonRpc exception.
 */
class NonRpcException extends BaseException
{
    public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
    {
        if ($code >= -32768 && $code <= -32000) {
            $code = 0;
        }
        parent::__construct($message, $code, $previous);
    }

    public static function build(
        string $message,
        int $code,
        array $data = []
    ): static {
        return (new static($message, $code))->fill($data);
    }
}
